package edu.scut.yi.yx.lobbymanager;

import com.electrotank.electroserver5.extensions.BasePlugin;
import com.electrotank.electroserver5.extensions.ChainAction;
import com.electrotank.electroserver5.extensions.api.value.EsObject;
import com.electrotank.electroserver5.extensions.api.value.EsObjectRO;
import com.electrotank.electroserver5.extensions.api.value.UserEnterContext;
import com.electrotank.electroserver5.extensions.api.value.UserPublicMessageContext;

import edu.scut.yi.yx.processer.AbstractProcesser;



public class LobbyManager extends BasePlugin{

	private Processers myProcessers;
	
	@Override
	public void init(EsObjectRO parameters) {
		// TODO Auto-generated method stub
		myProcessers = new Processers();
		getApi().getLogger().debug("****************new  a processers");
	}

	@Override
	public void request(String userName, EsObjectRO requestParameters) {
		// TODO Auto-generated method stub
		getApi().getLogger().debug(userName+" "+requestParameters.toString());
		getApi().getLogger().debug("lobbymanager.request :" + requestParameters.getString(Command.Action.getCode()));
		AbstractProcesser ap = myProcessers.forCommand(requestParameters.getString(Command.Action.getCode()));
		getApi().getLogger().debug("sendcommand to processer");
		if(ap != null){
		ap.process(userName, requestParameters, this.getApi());
		}
	}

	@Override
	public ChainAction userEnter(UserEnterContext context) {
		// TODO Auto-generated method stub
		return super.userEnter(context);
	}

	@Override
	public void userExit(String userName) {
		// TODO Auto-generated method stub
		super.userExit(userName);
	}

	@Override
	public ChainAction userSendPublicMessage(UserPublicMessageContext message) {
		// TODO Auto-generated method stub
		return super.userSendPublicMessage(message);
	}
    

}
